<div>
    <input type="file" id="upload[id]" name="upload[id]" />
    <input type="hidden" id="[id]" name="[id]" value="[value]" />
    <div id="div[id]" style="margin:10px 0px;">
        <a href="__ROOT__[value]" id="a[id]" target="_blank"><img id="img[id]" src="__ROOT__[value]" width="[width]" alt="点击查看原图"  /></a>
        &nbsp;<a href="#" onclick="delfile[id]('[id]')">删除</a>
    </div>
</div>
<script type="text/javascript">
    var value = "[value]";
    if (value == "")
    {
        $("#div[id]").hide();
    }
    $('#upload[id]').uploadify({
        'swf': '__PUBLIC__/common/uploadify/uploadify.swf")',
        'uploader': "{:U('Fwadmin/Login/uploadPic')}?path=[path]&thumbw=[thumbw]&thumbh=[thumbh]&sessionid={:session_id()}",
        'cancelImg': '__PUBLIC__/common/uploadify/uploadify-cancel.png',
        'buttonText': '选择图片',
        'auto': true,
        'height': 24,
        'width': 80,
        'multi': false,
        'fileTypeDesc': '图片文件',
        'fileTypeExts': '*.jpg;*.gif;*.png;*.bmp;',
        'fileSizeLimit': '2024KB',
        'removeTimeout': 0,
        'onUploadError': function(file, errorCode, errorMsg, errorString, swfuploadifyQueue) {
            if (errorCode !== "-280" && errorMsg !== "File Upload Cancelled.")
            {
                alert(errorMsg);
            }
        },
        'onCancel': function(event, queueID, file, data) {
            //  alert("取消成功！");
        },
        'onUploadSuccess': function(file, data, response) {
            if (response == true) {
                //alert(data);
                $("#div[id]").show();
                var json = eval('(' + data + ')');
                $("#[id]").val(json.SaveName);
                $("#a[id]").attr("href", '__ROOT__' + json.SaveName);
                $("#img[id]").attr("src", '__ROOT__' + json.SaveName);
            }
            else {
                alert("上传出错！");
            }
        }
    });

    //uploadify上传单文件删除文件
    function delfile[id](id) {
        var filename = $("#" + id).val();
        if (filename !== '')
        {
            $.ajax({
                url: "{:U('Fwadmin/Index/delPic')}?filename=" + filename,
                success: function(val)
                {
                    $("#" + id).val("");
                    $("#div" + id).hide();
                }
            });
            var filename2 = filename.replace('[path]', '[path]/thumb');
            $.ajax({
                url: "{:U('Fwadmin/Index/delPic')}?filename=" + filename2,
                success: function(val)
                {
                }
            })
        }
    }
</script>